# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libusb
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.0.24
pkgrel=2
pkgdesc="Library that provides generic access to USB devices (mingw-w64)"
arch=('any')
url="https://libusb.info/"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=('staticlibs' 'strip')
source=("https://github.com/libusb/libusb/releases/download/v${pkgver}/${_realname}-${pkgver}.tar.bz2")
sha256sums=('7efd2685f7b327326dcfb85cee426d9b871fd70e22caa15bb68d595ce2a2b12a')

build() {
  #export lt_cv_deplibs_check_method='pass_all'
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --enable-static

  make
}

check() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make check || true
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
